<?php
class Cms_RatingController extends Zend_Controller_Action {

    function init(){
        CmsAuth::check();
    
    }
    
    
    public function ratingAction(){
        $filter = new Zend_Filter_StripTags();		
		$id = $filter->filter($this->getRequest()->getParam('rating_id'));
    
        $rating = MF_Main::getInstance()->Rating->getById($id);
        
        $this->view->rating = $rating;
        $this->view->needClose = false;
        if( isset($_POST['ok']) ){
            $newscore = $filter->filter($_POST['newscore']);
            $voites = $filter->filter($_POST['amount']);
        
            $rating->adminVoite($newscore, $voites);
            $this->view->needClose = true;
        }
    }    
    
    public function getratingAction(){
        $filter = new Zend_Filter_StripTags();		
		$id = $filter->filter($this->getRequest()->getParam('id'));

		$rating = MF_Main::getInstance()->Rating->getById($id);
		
		echo $rating->score;
		$this->_helper->layout->disableLayout();    
    }
    
}